/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package TapestryModel.impl;

import TapestryModel.Activation;
import TapestryModel.ActivationMapping;
import TapestryModel.Attribute;
import TapestryModel.ContentAttirbute;
import TapestryModel.ContentObject;
import TapestryModel.Entity;
import TapestryModel.Form;
import TapestryModel.LinkMapping;
import TapestryModel.Page;
import TapestryModel.ParamLink;
import TapestryModel.PrimitiveType;
import TapestryModel.Reference;
import TapestryModel.SimpleLink;
import TapestryModel.Site;
import TapestryModel.TapestryModelFactory;
import TapestryModel.TapestryModelPackage;
import TapestryModel.Value;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class TapestryModelFactoryImpl extends EFactoryImpl implements TapestryModelFactory {
    /**
     * Creates the default factory implementation.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static TapestryModelFactory init() {
        try {
            TapestryModelFactory theTapestryModelFactory = (TapestryModelFactory)EPackage.Registry.INSTANCE.getEFactory("http://kovanovic.info/tapestry_model/1.0"); 
            if (theTapestryModelFactory != null) {
                return theTapestryModelFactory;
            }
        }
        catch (Exception exception) {
            EcorePlugin.INSTANCE.log(exception);
        }
        return new TapestryModelFactoryImpl();
    }

    /**
     * Creates an instance of the factory.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public TapestryModelFactoryImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public EObject create(EClass eClass) {
        switch (eClass.getClassifierID()) {
            case TapestryModelPackage.SITE: return createSite();
            case TapestryModelPackage.PAGE: return createPage();
            case TapestryModelPackage.ACTIVATION: return createActivation();
            case TapestryModelPackage.ACTIVATION_MAPPING: return createActivationMapping();
            case TapestryModelPackage.FORM: return createForm();
            case TapestryModelPackage.SIMPLE_LINK: return createSimpleLink();
            case TapestryModelPackage.PARAM_LINK: return createParamLink();
            case TapestryModelPackage.LINK_MAPPING: return createLinkMapping();
            case TapestryModelPackage.ENTITY: return createEntity();
            case TapestryModelPackage.ENUM: return createEnum();
            case TapestryModelPackage.VALUE: return createValue();
            case TapestryModelPackage.REFERENCE: return createReference();
            case TapestryModelPackage.ATTRIBUTE: return createAttribute();
            case TapestryModelPackage.CONTENT_OBJECT: return createContentObject();
            case TapestryModelPackage.CONTENT_ATTIRBUTE: return createContentAttirbute();
            default:
                throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
        }
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object createFromString(EDataType eDataType, String initialValue) {
        switch (eDataType.getClassifierID()) {
            case TapestryModelPackage.PRIMITIVE_TYPE:
                return createPrimitiveTypeFromString(eDataType, initialValue);
            default:
                throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
        }
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String convertToString(EDataType eDataType, Object instanceValue) {
        switch (eDataType.getClassifierID()) {
            case TapestryModelPackage.PRIMITIVE_TYPE:
                return convertPrimitiveTypeToString(eDataType, instanceValue);
            default:
                throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
        }
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Site createSite() {
        SiteImpl site = new SiteImpl();
        return site;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Page createPage() {
        PageImpl page = new PageImpl();
        return page;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Activation createActivation() {
        ActivationImpl activation = new ActivationImpl();
        return activation;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ActivationMapping createActivationMapping() {
        ActivationMappingImpl activationMapping = new ActivationMappingImpl();
        return activationMapping;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Form createForm() {
        FormImpl form = new FormImpl();
        return form;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public SimpleLink createSimpleLink() {
        SimpleLinkImpl simpleLink = new SimpleLinkImpl();
        return simpleLink;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ParamLink createParamLink() {
        ParamLinkImpl paramLink = new ParamLinkImpl();
        return paramLink;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public LinkMapping createLinkMapping() {
        LinkMappingImpl linkMapping = new LinkMappingImpl();
        return linkMapping;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Entity createEntity() {
        EntityImpl entity = new EntityImpl();
        return entity;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public TapestryModel.Enum createEnum() {
        EnumImpl enum_ = new EnumImpl();
        return enum_;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Value createValue() {
        ValueImpl value = new ValueImpl();
        return value;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Reference createReference() {
        ReferenceImpl reference = new ReferenceImpl();
        return reference;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Attribute createAttribute() {
        AttributeImpl attribute = new AttributeImpl();
        return attribute;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ContentObject createContentObject() {
        ContentObjectImpl contentObject = new ContentObjectImpl();
        return contentObject;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ContentAttirbute createContentAttirbute() {
        ContentAttirbuteImpl contentAttirbute = new ContentAttirbuteImpl();
        return contentAttirbute;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public PrimitiveType createPrimitiveTypeFromString(EDataType eDataType, String initialValue) {
        PrimitiveType result = PrimitiveType.get(initialValue);
        if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
        return result;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String convertPrimitiveTypeToString(EDataType eDataType, Object instanceValue) {
        return instanceValue == null ? null : instanceValue.toString();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public TapestryModelPackage getTapestryModelPackage() {
        return (TapestryModelPackage)getEPackage();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @deprecated
     * @generated
     */
    @Deprecated
    public static TapestryModelPackage getPackage() {
        return TapestryModelPackage.eINSTANCE;
    }

} //TapestryModelFactoryImpl
